//
//  GMRankDetailCell.m
//  Teecloud
//
//  Created by PC on 2018/10/26.
//  Copyright © 2018年 小志. All rights reserved.
//

#import "GMRankDetailCell.h"
#import "GMRankDetail.h"
@interface GMRankDetailCell ()
@property (weak, nonatomic) IBOutlet UILabel *rankNoLabel;
@property (weak, nonatomic) IBOutlet UIImageView *headImg;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *scoreLabel;
//排名的宽度
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *rankWidth;

@end
//培训中
#define SECOND [UIColor colorWithHexString:@"#FF9900" andAlpha:1.0]
#define THIRD [UIColor colorWithHexString:@"#88C800" andAlpha:1.0]
@implementation GMRankDetailCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.rankNoLabel.layer.cornerRadius = 5.0f;
    self.rankNoLabel.clipsToBounds = YES;
}
- (void)setModel:(GMRankDetail *)model{
    _model = model;
    if ([model.RankNo isEqualToNumber:@(1)]) {
        self.rankNoLabel.backgroundColor = kRedColor;
    }else if ([model.RankNo isEqualToNumber:@(2)]){
        self.rankNoLabel.backgroundColor = SECOND;
    }else if ([model.RankNo isEqualToNumber:@(3)]){
        self.rankNoLabel.backgroundColor = THIRD;
    }
    self.rankNoLabel.text = [NSString stringWithFormat:@"%@",model.RankNo];
    [self.headImg yy_setImageWithURL:[NSURL URLWithString:model.HeadUrl] placeholder:DefealtImg];
    self.nameLabel.text = model.Name;
    self.scoreLabel.text = model.Memo;
    
    NSString *rankNoStr = [NSString stringWithFormat:@"%@",model.RankNo];
    CGSize titleSize = [rankNoStr boundingRectWithSize:CGSizeMake(MAXFLOAT, 25) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:self.rankNoLabel.font} context:nil].size;
    self.rankWidth.constant = titleSize.width+30;
}

@end
